home *** CD-ROM | disk | FTP | other *** search
/ Deutsche Edition 1 / Deutsche Edition 1.iso / amok / amok_lha / amok24.lha / TurboFiles / asm / TurboGetPos.asm < prev    next >
Assembly Source File  |  1993-08-15  |  3KB  |  86 lines

  1. ;Assemblerversion of the Procedure GetPos from the Module TurboFiles
  2. ;Created: 11.6.89 by
  3. ;     Stefan Salewski
  4. ;     Stolper Weg 3
  5. ;     2160 Stade
  6.  
  7. ;-------------------------------------------------------------------
  8. ;The Modula-procedure-header:
  9. ;PROCEDURE TurboGetPos(VAR f{11}:File):LONGINT;
  10. ;-------------------------------------------------------------------
  11. ;TYPE
  12. ;Result=(notOpen,done,notdone,openError,readError,writeError,seekError,
  13. ;        endOfFile,outOfMem,tooManyFiles);
  14. notOpen        EQU     0
  15. done           EQU     1
  16. notDone        EQU     2
  17. openError      EQU     3
  18. readError      EQU     4
  19. writeError     EQU     5
  20. seekError      EQU     6
  21. endOfFile      EQU     7
  22. outOfMem       EQU     8
  23. tooManyFile    EQU     9
  24. ;-------------------------------------------------------------------
  25. ;Modes of Dos.Seek
  26. Dos_beginning  EQU    -1
  27. Dos_current    EQU     0
  28. Dos_end        EQU     1
  29. ;-------------------------------------------------------------------
  30. ;The Modula-Datastructure:
  31. ;File=RECORD
  32. ;       fhPtr:Dos.FileHandlePtr;
  33. ;       dosBase:ADDRESS;
  34. ;       base:ADDRESS;
  35. ;       top:ADDRESS;
  36. ;       filePos:LONGINT;
  37. ;       startLength:LONGINT;
  38. ;       act:CharPtr;
  39. ;       readTop:ADDRESS;
  40. ;       writeBase:ADDRESS;
  41. ;       writeTop:ADDRESS;
  42. ;       res:Result;
  43. ;     END;
  44.  
  45. ;The offsets in the File-Variable:
  46. _fhPtr          EQU     0
  47. _dosBase        EQU     4
  48. _base           EQU     8
  49. _top            EQU     12
  50. _filePos        EQU     16
  51. _startLength    EQU     20
  52. _act            EQU     24
  53. _readTop        EQU     28
  54. _writeBase      EQU     32
  55. _writeTop       EQU     36
  56. _res            EQU     40
  57. ;-------------------------------------------------------------------
  58. ;The offsets of the Dos-functions:
  59. _Seek           EQU    -66
  60. _Write          EQU    -48
  61. _Read           EQU    -42
  62. ;-------------------------------------------------------------------
  63. ; We can use all registers except A4, A5 (and A7 of course)
  64. ; A0, A1, D0, D1 are not resistent against changes by Dos-Funktions,
  65. ; and I changes than too by myself.
  66. ; I don't use D0 and D1 as registerparameters in the ProcedureHaeder,
  67. ; because they are used to evaluate the Procedure-parameters.
  68. ;-------------------------------------------------------------------
  69. ;The address of the file-variable I get from the Compiler in the register A3
  70. ;The result is allways given back in D0
  71.  
  72. f      EQUR  A3; ADDRESS (The address of the file-variable)
  73. ;-------------------------------------------------------------------
  74. Start: ;(of GetPos)
  75.        CMPI.B  #done,_res(f)
  76.        BNE.S   Error
  77.        MOVE.L  _filePos(f),D0
  78.        ADD.L   _act(f),D0
  79.        SUB.L   _readTop(f),D0
  80.        RTS
  81. Error:
  82.        MOVEQ.L #-1,D0
  83. TheEnd:
  84.        RTS
  85.        END
  86.